{% extends 'base.html' %}
{% block title %}
    网站首页
{% endblock %}
{% block content %}
    <style>
        .ellipsis {
            width: 300px;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }
    </style>
    <div class="actions">
        <a class="btn btn-primary" href="/article_add">新增</a>
    </div>
    <hr>
    <table class="table table-bordered table-hover table-striped">
        <thead>
        <tr class="table-active">
            <th style="width: 8%">序号</th>
            <th style="width: 10%">封面</th>
            <th style="width: 10%">分类</th>
            <th style="width: 20%">标题</th>
            <th style="width: 10%">作者</th>
            <th style="width: 20%">发布时间</th>
            <th style="width: 22%">操作</th>
        </tr>
        </thead>
        <tbody>
        {% for item in data.article_list %}
            <tr>
                <td>{{ item.id }}</td>
                <td>
                    <img style="width:100px" src="{{ url_for("static",filename="imgs/news-cover.jpg") }}" alt="">
                </td>
                <td> 暂无分类</td>
                <td>
                    <div class="ellipsis">
                        {{ item.title }}
                    </div>
                </td>
                <td>{{ item.author.real_name }}</td>
                <td>{{ item.create_time }}</td>
                <td>
                    {% set url="/news_detail?id=%s"%(item.id) %}

                    <a class="btn btn-outline-primary btn-sm" href="{{ url }}">查看详情</a>
                    <a class="btn btn-outline-primary btn-sm">编辑</a>
                    <a class="btn btn-outline-primary btn-sm" href="/article_del/{{ item.id }}">删除</a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
{% endblock %}
